﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.Controls;

namespace YJKWallDesignation
{
	public partial class SetSuffixNameForm : System.Windows.Forms.Form
	{
		public SetSuffixNameForm(string oldName, List<string> nameList)
		{
			this.InitializeComponent();
			this.m_OldNameList = nameList;
			this.tbSuffix.Text = oldName;
		}

		public string SuffixName
		{
			get
			{
				return this.tbSuffix.Text;
			}
		}

		private void SetSuffixNameForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (((System.Windows.Forms.Form)sender).DialogResult == DialogResult.OK)
			{
				using (List<string>.Enumerator enumerator = this.m_OldNameList.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						if (enumerator.Current.CompareTo(this.SuffixName) == 0)
						{
							YJKMessageBox.Show("新名称在列表中已经存在。");
							e.Cancel = true;
							break;
						}
					}
				}
			}
		}

		private List<string> m_OldNameList = new List<string>();
	}
}
